# -*-coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf-8')

import logging
from flask import Flask
from celery import Celery
from flask import request
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy import and_

app = Flask(__name__)

app.config['SQLALCHEMY_DATABASE_URI'] = "mysql://root:xh881001@127.0.0.1/crawler"

db = SQLAlchemy(app)

celery = Celery(__name__, broker='redis://localhost:6379/2')
celery.conf.CELERY_EAGER_PROPAGATES_EXCEPTIONS = True
#celery.conf.CELERY_ROUTES = {'utils.sms': {'queue': 'sms'}, 'utils.order': {'queue': 'order'}}

# add for hourly logger
afile = logging.handlers.TimedRotatingFileHandler('/tmp/getcash', when='h', interval=1)
afile.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
afile.setFormatter(formatter)
app.logger.addHandler(afile)

